package com.atguigu.guli.service.edu.controller.admin;


import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Subject;
import com.atguigu.guli.service.edu.service.SubjectService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-06-24
 */
@Api(tags = "课程分类管理模块")
@RestController
@RequestMapping("/admin/edu/subject")
@CrossOrigin
public class AdminSubjectController {

    @Autowired
    private SubjectService subjectService;

    //文件上传
    @PostMapping("import")
    public R importSubjects(MultipartFile file) {

        subjectService.importSubjects(file);

        return R.ok();
    }

    // 查询课程分类 getSubjectsNestedList
    @GetMapping("getSubjectsNestedList")
    public R getSubjectsNestedList() {
        List<Subject> parentSubjects = subjectService.getSubjectsNestedList();

        return R.ok().data("items", parentSubjects);
    }

}

